package com.cskaoyan.service;

import com.cskaoyan.mapper.AccountMapper;

/***
 * title AccountServiceImpl
 * @description <TODO description class purpose>
 * @author ZCZ
 * @version 1.0.0
 * @create 2022/9/1 19:47
 **/
public class AccountServiceImpl implements AccountService{

    AccountMapper accountMapper;
    @Override
    public void transfer(int fromId, int destId, int money) {
        int fromMoney = accountMapper.selectMoneyById(fromId);
        int destMoney = accountMapper.selectMoneyById(destId);
        fromMoney-=money;
        destMoney+=money;

        accountMapper.updateMoneyById(fromId,fromMoney);
        accountMapper.updateMoneyById(destId,destMoney);


    }
}
